#include "publisheractivator.h"

#include <QDebug>
#include <QThread>
#include <service/event/ctkEventAdmin.h>

void PublisherActivator::start(ctkPluginContext *context)
{
    Q_UNUSED(context)
    qDebug() << Q_FUNC_INFO << "插件启动" << "发布信息";

    //sendEvent 同步通信demo
    ctkServiceReference ref = context->getServiceReference<ctkEventAdmin>();
    ctkEventAdmin *eventAdmin = qobject_cast<ctkEventAdmin*>(context->getService(ref));
    ctkProperties props;
    props.insert("username", "Publisher插件");
    ctkEvent event("topic/subscriber_publisher_demo", props);
    if(nullptr != eventAdmin)
        eventAdmin->sendEvent(event);
}

void PublisherActivator::stop(ctkPluginContext *context)
{
    Q_UNUSED(context)
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
Q_EXPORT_PLUGIN2(Publisher, PublisherActivator)
#endif
